const env = 'production';

const hosts = {
  development: '',
  production: 'https://as365.try0574.com/api/v1'
  //production: 'https://www.91ygp.com/api/v1'
}

const api = {
  member: {
    indexPage: { //用户首页 接口
      method: 'GET',
      url: '/index'
    },
    recharge: { //余额充值
      method: 'POST',
      url: '/member/pay'
    },
    setMeal: { //套餐获取
      method: 'GET',
      url: '/base/set-meal'
    },
    setMealRecharge: { //套餐充值
      method: 'POST',
      url: '/base/set-meal'
    },
    setMealList: { //套餐列表获取
      method: 'GET',
      url: '/base/meal-info'
    },
    setMealPay: { //购买套餐确认支付
      method: 'GET',
      url: '/base/meal-info/addmeal'
    },
    setMealUpgrade: { //购买套餐 续费或者升级
      method: 'GET',
      url: '/base/meal-info/upgrade'
    },
    setMealInfo: { //套餐消费记录剩余信息
      method: 'GET',
      url: '/base/meal-info/meallist'
    },
    setMealRecord: { //套餐消费记录列表
      method: 'GET',
      url: '/base/meal-info/recordlist'
    },
    setMealOverdue: { //套餐是否过期
      method: 'GET',
      url: '/base/meal-info/overdue'
    },
    integral: { //积分接口
      method: 'POST',
      url: '/member/integral'
    },
  },
  contract: {
    contractSupervisorPay: { //合同监理支付
      method: 'POST',
      url: '/member/contract-supervisor/pay'
    },
    contractDetail: { //合同监理详情
      method: 'GET',
      url: '/member/contract-supervisor'
    },
    payInfo: { //合同监理支付信息
      method: 'GET',
      url: '/member/contract-supervisor/pay-info'
    },
    sendLetter: { //发送律师函
      method: 'POST',
      url: '/contract/law-office'
    },
    mandatary: { //被监理方列表
      method: 'GET',
      url: '/contract/mandatary'
    },
    agency: { //中介中标
      method: 'PUT',
      url: '/contract/order'
    },
    chooseAgencyInfo: { //选择执行中介 页面信息
      method: 'GET',
      url: '/contract/supervisor'
    },
    buildConsensus: { //舆论创建
      method: 'POST',
      url: '/contract/consensus'
    },
    contractLogs: { //合同详情中的 操作记录
      method: 'GET',
      url: '/contract/logs'
    },
  },
  downloadContract: {
    serviceAgreement: { //下载合同列表 进去的页面
      method: 'GET',
      url: '/base/contract'
    },
  },
  base: { //配置信息
    serviceAgreement: { //获取服务协议信息
      method: 'GET',
      url: '/base/config'
    },
    contractType: { //获取合同类型
      method: 'GET',
      url: '/base/contract-cate'
    },
    agencyList: { //获取代理机构
      method: 'GET',
      url: '/member/grade'
    },
    attorneyMoney: { //获取律师费
      method: 'GET',
      url: '/base/config'
    },
  }
}

module.exports = {
  env,
  api: disposeUrl(api, hosts[env])
}

function disposeUrl(obj, prefix) {
  Object.keys(obj).forEach(v => {
    if (obj[v].url) {
      obj[v].url = prefix + obj[v].url
    } else {
      obj[v] = disposeUrl(obj[v], prefix)
    }
  })
  return obj
}